package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.NewsPage;
import cn.wolfcode.trip.base.query.NewsPageQueryObject;
import cn.wolfcode.trip.base.service.INewsPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/newsPage")
public class NewsPageController {
    @Autowired
    private INewsPageService newsPageService;

    /**
     * 获取所有日报
     * 资源:/newsPage
     * 动作:GET
     * 参数:state=1
     */
    @GetMapping
    public Object getNewsPage(NewsPageQueryObject qo){
        qo.setOrderBy("createTime desc");
        qo.setState(NewsPage.STATE_WAIT);
        return newsPageService.query(qo);
    }

    /**
     * 获取相关推荐日报
     * 资源:/newsPage/{id}
     * 动作:GET
     */
    @GetMapping("/{id}")
    public Object getRecommendNews(@PathVariable Long id){

        return newsPageService.selectRecommendNews(id);
    }

}
